aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/GameObject.h1
-rw-r--r--src/game/Object.cpp23
-rw-r--r--src/game/Object.h3
3 files changed, 26 insertions, 1 deletions
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index bfd265a9818..20c583d30b3 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -494,6 +494,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
(m_respawnTime == 0 && m_spawnedByDefault);
}
bool isSpawnedByDefault() const { return m_spawnedByDefault; }
+ void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
void Refresh();
void Delete();
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index cbe40ffb593..be66efde0ad 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1435,6 +1435,29 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
return pCreature;
}
+GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
+{
+ if(!IsInWorld())
+ return NULL;
+ Map * map = GetMap();
+ if(!map)
+ return NULL;
+ GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(entry);
+ if(!goinfo)
+ {
+ sLog.outErrorDb("Gameobject template %u not found in database!", entry);
+ return NULL;
+ }
+ GameObject *go = new GameObject();
+ if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry,map,x,y,z,ang,rotation0,rotation1,rotation2,rotation3,100,1))
+ return NULL;
+ go->SetRespawnTime(respawnTime);
+ go->SetSpawnedByDefault(false); // do not save respawn time
+ map->Add(go);
+
+ return go;
+}
+
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle ) const
{
x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
diff --git a/src/game/Object.h b/src/game/Object.h
index d290838b486..0a5e0e1f6f7 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -91,6 +91,7 @@ class Player;
class Map;
class UpdateMask;
class InstanceData;
+class GameObject;
typedef HM_NAMESPACE::hash_map<Player*, UpdateData> UpdateDataMapType;
@@ -445,7 +446,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
Map * GetMap() const;
Map const* GetBaseMap() const;
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime);
-
+ GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
protected:
explicit WorldObject();
std::string m_name;